In [1]:
import cv2
import numpy as np
import matplotlib.pyplot as plt
import scipy.ndimage as scp
In [2]:
img = cv2.imread('bike.jpg', cv2.IMREAD_GRAYSCALE)
In [3]:
im_filter = np.zeros((3,3))
im_filter[1,1] = 1
filtered_image = scp.correlate(img, im_filter)
In [4]:
plt.figure(figsize=(10,8))
plt.subplot(1,2,1), plt.imshow(img, cmap='gray'), plt.title('Original')
Out[4]:
In [5]:
plt.subplot(1,2,2), plt.imshow(filtered_image, cmap='gray'), plt.title('Impulse Filtered (Centered)')
Out[5]:
In [6]:
plt.show()